<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script typet="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
	<center>
		<table border="1">
			<tr>
				<td>用户名</td>
				<td>详细地址</td>
				<td>操作</td>
			</tr>
			
			<tr>
				<td>{$data[0]['uname']}</td>
				<td class="adds">{$data[0]['address']}</td>
				<td><button>饭店</button> | <button>酒店</button></td>
			</tr>
			
		</table>
		<tr>
				<td><div style="width: 200px;height: 100px; " id="allmap"></div></td>
			</tr>
			
	</center>
</body>
</html>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=5f5cxSUq0v6e970e4vCunMEqscWzercy"></script>
<script>
		$("button").click(function(){
			var uname=$(this).text();
			var adds=$(".adds").text();
			$.ajax({
				type:'post',
				url:'{url:/day6/ajax}',
				dataType:'json',
				data:{
					adds:adds
				},
				success:function(daat){
					var lat=daat.lat;
					var lng=daat.lng;
							if(uname=="饭店"){
	var map = new BMap.Map("allmap");            // 创建Map实例
	var mPoint = new BMap.Point(lng, lat);  
	map.enableScrollWheelZoom();
	map.centerAndZoom(mPoint,15);

	var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
    map.addOverlay(circle);
    var local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});  
    local.searchNearby('餐馆',mPoint,1000);
			}
			if(uname=="酒店"){
var map = new BMap.Map("allmap");            // 创建Map实例
	var mPoint = new BMap.Point(lng, lat);  
	map.enableScrollWheelZoom();
	map.centerAndZoom(mPoint,18);

	var circle = new BMap.Circle(mPoint,1000,{fillColor:"blue", strokeWeight: 1 ,fillOpacity: 0.3, strokeOpacity: 0.3});
    map.addOverlay(circle);
    var local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});  
    local.searchNearby('酒店',mPoint,3000);
			}

				}
			})
	


		})


</script>